package demo.db.mysql.vo;

import java.util.Map;

public class BinLogMsg {

    private String eventId;

    private String schemaName;

    private String tableName;

    private String fullName;

    private String eventType;

    private Long timestamp;

    private Boolean ddl;

    private Long position;

    private Long nextPosition;

    private String binlogFileName;

    private Integer rowSeq;

    private Long serverId;

    private String sqlStatement;

    private BinlogInfo tmeBinlogInfo;

    private Map<String, String> rowBefore;

    private Map<String, String> rowAfter;

    private Map<String, String> afterType;

    private String partitionKey;

    public String getEventId() {
        return eventId;
    }

    public void setEventId(String eventId) {
        this.eventId = eventId;
    }

    public String getSchemaName() {
        return schemaName;
    }

    public void setSchemaName(String schemaName) {
        this.schemaName = schemaName;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    public String getEventType() {
        return eventType;
    }

    public void setEventType(String eventType) {
        this.eventType = eventType;
    }

    public Long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Long timestamp) {
        this.timestamp = timestamp;
    }

    public Boolean getDdl() {
        return ddl;
    }

    public boolean isDdl() {
        return Boolean.TRUE.equals(ddl);
    }

    public void setDdl(Boolean ddl) {
        this.ddl = ddl;
    }

    public Long getPosition() {
        return position;
    }

    public void setPosition(Long position) {
        this.position = position;
    }

    public Long getNextPosition() {
        return nextPosition;
    }

    public void setNextPosition(Long nextPosition) {
        this.nextPosition = nextPosition;
    }

    public String getBinlogFileName() {
        return binlogFileName;
    }

    public void setBinlogFileName(String binlogFileName) {
        this.binlogFileName = binlogFileName;
    }

    public Integer getRowSeq() {
        return rowSeq;
    }

    public void setRowSeq(Integer rowSeq) {
        this.rowSeq = rowSeq;
    }

    public Long getServerId() {
        return serverId;
    }

    public void setServerId(Long serverId) {
        this.serverId = serverId;
    }

    public String getSqlStatement() {
        return sqlStatement;
    }

    public void setSqlStatement(String sqlStatement) {
        this.sqlStatement = sqlStatement;
    }

    public BinlogInfo getTmeBinlogInfo() {
        return tmeBinlogInfo;
    }

    public void setTmeBinlogInfo(BinlogInfo tmeBinlogInfo) {
        this.tmeBinlogInfo = tmeBinlogInfo;
    }

    public Map<String, String> getRowBefore() {
        return rowBefore;
    }

    public void setRowBefore(Map<String, String> rowBefore) {
        this.rowBefore = rowBefore;
    }

    public Map<String, String> getRowAfter() {
        return rowAfter;
    }

    public void setRowAfter(Map<String, String> rowAfter) {
        this.rowAfter = rowAfter;
    }

    public Map<String, String> getAfterType() {
        return afterType;
    }

    public void setAfterType(Map<String, String> afterType) {
        this.afterType = afterType;
    }

    public String getPartitionKey() {
        return partitionKey;
    }

    public void setPartitionKey(String partitionKey) {
        this.partitionKey = partitionKey;
    }

    // 新增
    public static boolean isCreate(String eventType) {
        EventType event = EventType.getEventType(eventType);
        return event == EventType.PRE_GA_WRITE_ROWS || event == EventType.WRITE_ROWS
                || event == EventType.EXT_WRITE_ROWS;
    }

    // 修改
    public static boolean isUpdate(String eventType) {
        EventType event = EventType.getEventType(eventType);
        return event == EventType.PRE_GA_UPDATE_ROWS || event == EventType.UPDATE_ROWS
                || event == EventType.EXT_UPDATE_ROWS;
    }

    // 删除
    public static boolean isDelete(String eventType) {
        EventType event = EventType.getEventType(eventType);
        return event == EventType.PRE_GA_DELETE_ROWS || event == EventType.DELETE_ROWS
                || event == EventType.EXT_DELETE_ROWS;
    }
}
